<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>管理员管理系统</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Microsoft YaHei', sans-serif;
        }

        body {
            background-color: #f5f5f5;
            color: #333;
        }

        .header {
            background-color: #409EFF;
            color: white;
            padding: 15px 30px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }

        .header h1 {
            font-size: 24px;
        }

        .user-info {
            display: flex;
            align-items: center;
            gap: 15px;
        }

        .user-name {
            font-weight: bold;
        }

        .logout-btn {
            background-color: transparent;
            color: white;
            border: 1px solid white;
            padding: 5px 15px;
            border-radius: 4px;
            cursor: pointer;
            transition: all 0.3s;
        }

        .logout-btn:hover {
            background-color: white;
            color: #409EFF;
        }

        .container {
            display: flex;
            min-height: calc(100vh - 60px);
        }

        .sidebar {
            width: 220px;
            background-color: white;
            box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
            padding: 20px 0;
        }

        .menu-item {
            padding: 15px 25px;
            cursor: pointer;
            transition: all 0.3s;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .menu-item:hover {
            background-color: #f0f7ff;
            color: #409EFF;
        }

        .menu-item.active {
            background-color: #e1f0ff;
            color: #409EFF;
            border-left: 4px solid #409EFF;
        }

        .main-content {
            flex: 1;
            padding: 25px;
            background-color: #f9f9f9;
        }

        .card {
            background-color: white;
            border-radius: 6px;
            box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
            padding: 20px;
            margin-bottom: 20px;
        }

        .card-title {
            font-size: 18px;
            margin-bottom: 15px;
            padding-bottom: 10px;
            border-bottom: 1px solid #eee;
            color: #409EFF;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        table {
            width: 100%;
            border-collapse: collapse;
        }

        th, td {
            padding: 12px 15px;
            text-align: left;
            border-bottom: 1px solid #eee;
        }

        th {
            background-color: #f5f7fa;
            font-weight: 600;
        }

        tr:hover {
            background-color: #f5f7fa;
        }

        .action-btn {
            padding: 5px 10px;
            border-radius: 4px;
            cursor: pointer;
            border: none;
            transition: all 0.3s;
            margin-right: 5px;
        }

        .add-btn {
            background-color: #67C23A;
            color: white;
        }

        .add-btn:hover {
            background-color: #5daf34;
        }

        .edit-btn {
            background-color: #409EFF;
            color: white;
        }

        .edit-btn:hover {
            background-color: #3a8ee6;
        }

        .delete-btn {
            background-color: #F56C6C;
            color: white;
        }

        .delete-btn:hover {
            background-color: #e05c5c;
        }

        .search-bar {
            display: flex;
            margin-bottom: 20px;
            gap: 10px;
        }

        .search-input {
            flex: 1;
            padding: 8px 12px;
            border: 1px solid #ddd;
            border-radius: 4px;
        }

        .search-btn {
            padding: 8px 15px;
            background-color: #409EFF;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }

        .modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.5);
            z-index: 1000;
            justify-content: center;
            align-items: center;
        }

        .modal-content {
            background-color: white;
            border-radius: 6px;
            width: 500px;
            max-width: 90%;
            padding: 20px;
            box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
            max-height: 90vh;
            overflow-y: auto;
        }

        .modal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            padding-bottom: 10px;
            border-bottom: 1px solid #eee;
        }

        .modal-title {
            font-size: 18px;
            font-weight: bold;
        }

        .close-btn {
            background: none;
            border: none;
            font-size: 20px;
            cursor: pointer;
            color: #999;
        }

        .form-group {
            margin-bottom: 15px;
        }

        .form-group label {
            display: block;
            margin-bottom: 5px;
            font-weight: 500;
        }

        .form-group input, .form-group select {
            width: 100%;
            padding: 8px 12px;
            border: 1px solid #ddd;
            border-radius: 4px;
        }

        .form-row {
            display: flex;
            gap: 15px;
        }

        .form-row .form-group {
            flex: 1;
        }

        .modal-footer {
            display: flex;
            justify-content: flex-end;
            gap: 10px;
            margin-top: 20px;
            padding-top: 15px;
            border-top: 1px solid #eee;
        }

        .btn {
            padding: 8px 15px;
            border-radius: 4px;
            cursor: pointer;
            border: none;
            transition: all 0.3s;
        }

        .btn-primary {
            background-color: #409EFF;
            color: white;
        }

        .btn-primary:hover {
            background-color: #3a8ee6;
        }

        .btn-cancel {
            background-color: #f5f5f5;
            color: #666;
        }

        .btn-cancel:hover {
            background-color: #e5e5e5;
        }

        .no-data {
            text-align: center;
            padding: 40px;
            color: #999;
        }

        .loading {
            text-align: center;
            padding: 20px;
        }

        .error-message {
            color: #F56C6C;
            margin-top: 10px;
        }

        .role-selector {
            display: flex;
            gap: 15px;
            margin-bottom: 15px;
        }

        .role-tab {
            padding: 8px 15px;
            border: 1px solid #ddd;
            border-radius: 4px;
            cursor: pointer;
            transition: all 0.3s;
        }

        .role-tab.active {
            background-color: #409EFF;
            color: white;
            border-color: #409EFF;
        }

        .role-form {
            display: none;
        }

        .role-form.active {
            display: block;
        }

        .tabs {
            display: flex;
            border-bottom: 1px solid #ddd;
            margin-bottom: 20px;
        }

        .tab {
            padding: 10px 20px;
            cursor: pointer;
            border-bottom: 2px solid transparent;
        }

        .tab.active {
            border-bottom: 2px solid #409EFF;
            color: #409EFF;
            font-weight: 500;
        }
    </style>
</head>
<body>
<div class="header">
    <h1>学生成绩管理系统 - 管理员</h1>
    <div class="user-info">
        <span class="user-name" id="adminName">加载中...</span>
        <button class="logout-btn" id="logoutBtn">退出登录</button>
    </div>
</div>

<div class="container">
    <div class="sidebar">
        <div class="menu-item active" data-page="user-management">
            <i>👥</i> 用户管理
        </div>
        <div class="menu-item" data-page="course-management">
            <i>📚</i> 课程管理
        </div>
        <div class="menu-item" data-page="teacher-management">
            <i>👨‍🏫</i> 教师管理
        </div>
        <div class="menu-item" data-page="student-management">
            <i>👨‍🎓</i> 学生管理
        </div>
    </div>

    <div class="main-content">
        <!-- 用户管理页面 -->
        <div id="user-management-page" class="page-content">
            <div class="card">
                <h2 class="card-title">
                    <span>用户管理</span>
                    <button class="action-btn add-btn" id="addUserBtn">添加用户</button>
                </h2>
                <div class="search-bar">
                    <input type="text" id="user-search" class="search-input" placeholder="输入真实姓名搜索">
                    <button class="search-btn" id="user-search-btn">搜索</button>
                </div>
                <table>
                    <thead>
                    <tr>
                        <th>ID</th>
                        <th>用户名</th>
                        <th>真实姓名</th>
                        <th>角色</th>
                        <th>创建时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody id="users-table">
                    <!-- 用户数据将通过JS动态填充 -->
                    </tbody>
                </table>
                <div id="users-error" class="error-message" style="display: none;"></div>
            </div>
        </div>

        <!-- 课程管理页面 -->
        <div id="course-management-page" class="page-content" style="display: none;">
            <div class="card">
                <h2 class="card-title">
                    <span>课程管理</span>
                    <button class="action-btn add-btn" id="addCourseBtn">添加课程</button>
                </h2>
                <div class="search-bar">
                    <input type="text" id="course-search" class="search-input" placeholder="输入课程名称搜索">
                    <button class="search-btn" id="course-search-btn">搜索</button>
                </div>
                <table>
                    <thead>
                    <tr>
                        <th>ID</th>
                        <th>课程号</th>
                        <th>课程名称</th>
                        <th>课时</th>
                        <th>教师</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody id="courses-table">
                    <!-- 课程数据将通过JS动态填充 -->
                    </tbody>
                </table>
                <div id="courses-error" class="error-message" style="display: none;"></div>
            </div>
        </div>

        <!-- 教师管理页面 -->
        <div id="teacher-management-page" class="page-content" style="display: none;">
            <div class="card">
                <h2 class="card-title">
                    <span>教师管理</span>
                    <button class="action-btn add-btn" id="addTeacherBtn">添加教师</button>
                </h2>
                <table>
                    <thead>
                    <tr>
                        <th>ID</th>
                        <th>教师号</th>
                        <th>姓名</th>
                        <th>性别</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody id="teachers-table">
                    <!-- 教师数据将通过JS动态填充 -->
                    </tbody>
                </table>
                <div id="teachers-error" class="error-message" style="display: none;"></div>
            </div>
        </div>

        <!-- 学生管理页面 -->
        <div id="student-management-page" class="page-content" style="display: none;">
            <div class="card">
                <h2 class="card-title">
                    <span>学生管理</span>
                    <button class="action-btn add-btn" id="addStudentBtn">添加学生</button>
                </h2>
                <table>
                    <thead>
                    <tr>
                        <th>ID</th>
                        <th>学号</th>
                        <th>姓名</th>
                        <th>性别</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody id="students-table">
                    <!-- 学生数据将通过JS动态填充 -->
                    </tbody>
                </table>
                <div id="students-error" class="error-message" style="display: none;"></div>
            </div>
        </div>
    </div>
</div>

<!-- 添加/编辑用户模态框 -->
<div class="modal" id="userModal">
    <div class="modal-content">
        <div class="modal-header">
            <span class="modal-title" id="userModalTitle">添加用户</span>
            <button class="close-btn" id="closeUserModal">&times;</button>
        </div>
        <div class="modal-body">
            <div class="tabs">
                <div class="tab active" data-role="common">基本信息</div>
                <div class="tab" data-role="student">学生信息</div>
                <div class="tab" data-role="teacher">教师信息</div>
            </div>

            <!-- 基本信息表单 -->
            <div id="common-form" class="role-form active">
                <div class="form-row">
                    <div class="form-group">
                        <label for="user-username">用户名 *</label>
                        <input type="text" id="user-username" required>
                    </div>
                    <div class="form-group">
                        <label for="user-password">密码 *</label>
                        <input type="password" id="user-password" required>
                    </div>
                </div>

                <div class="form-row">
                    <div class="form-group">
                        <label for="user-realname">真实姓名 *</label>
                        <input type="text" id="user-realname" required>
                    </div>
                    <div class="form-group">
                        <label for="user-role">角色 *</label>
                        <select id="user-role">
                            <option value="student">学生</option>
                            <option value="teacher">教师</option>
                            <option value="admin">管理员</option>
                        </select>
                    </div>
                </div>
            </div>

            <!-- 学生信息表单 -->
            <div id="student-form" class="role-form">
                <div class="form-row">
                    <div class="form-group">
                        <label for="student-sno">学号 *</label>
                        <input type="text" id="student-sno">
                    </div>
                    <div class="form-group">
                        <label for="student-gender">性别 *</label>
                        <select id="student-gender">
                            <option value="男">男</option>
                            <option value="女">女</option>
                        </select>
                    </div>
                </div>
            </div>

            <!-- 教师信息表单 -->
            <div id="teacher-form" class="role-form">
                <div class="form-row">
                    <div class="form-group">
                        <label for="teacher-tno">教师号 *</label>
                        <input type="text" id="teacher-tno">
                    </div>
                    <div class="form-group">
                        <label for="teacher-gender">性别 *</label>
                        <select id="teacher-gender">
                            <option value="男">男</option>
                            <option value="女">女</option>
                        </select>
                    </div>
                </div>
            </div>
            <input type="hidden" id="user-id">
        </div>
        <div class="modal-footer">
            <button class="btn btn-cancel" id="cancelUser">取消</button>
            <button class="btn btn-primary" id="saveUser">保存</button>
        </div>
    </div>
</div>

<!-- 添加/编辑课程模态框 -->
<div class="modal" id="courseModal">
    <div class="modal-content">
        <div class="modal-header">
            <span class="modal-title" id="courseModalTitle">添加课程</span>
            <button class="close-btn" id="closeCourseModal">&times;</button>
        </div>
        <div class="modal-body">
            <div class="form-row">
                <div class="form-group">
                    <label for="course-cno">课程号 *</label>
                    <input type="text" id="course-cno" required>
                </div>
                <div class="form-group">
                    <label for="course-cname">课程名称 *</label>
                    <input type="text" id="course-cname" required>
                </div>
            </div>

            <div class="form-row">
                <div class="form-group">
                    <label for="course-chours">课时 *</label>
                    <input type="number" id="course-chours" min="1" required>
                </div>
                <div class="form-group">
                    <label for="course-status">状态 *</label>
                    <select id="course-status">
                        <option value="yes">启用</option>
                        <option value="no">停用</option>
                    </select>
                </div>
            </div>

            <div class="form-row">
                <div class="form-group">
                    <label for="course-teacher">授课教师</label>
                    <input type="text" id="course-teacher" placeholder="教师姓名">
                </div>
                <div class="form-group">
                    <label for="course-classcode">班级代码</label>
                    <input type="number" id="course-classcode">
                </div>
            </div>
            <input type="hidden" id="course-id">
        </div>
        <div class="modal-footer">
            <button class="btn btn-cancel" id="cancelCourse">取消</button>
            <button class="btn btn-primary" id="saveCourse">保存</button>
        </div>
    </div>
</div>

<!-- 删除确认模态框 -->
<div class="modal" id="deleteModal">
    <div class="modal-content">
        <div class="modal-header">
            <span class="modal-title">确认删除</span>
            <button class="close-btn" id="closeDeleteModal">&times;</button>
        </div>
        <div class="modal-body">
            <p>您确定要删除 <strong id="delete-item-name"></strong> 吗？</p>
        </div>
        <div class="modal-footer">
            <button class="btn btn-cancel" id="cancelDelete">取消</button>
            <button class="btn btn-primary" id="confirmDelete">确认</button>
        </div>
    </div>
</div>

<script src="admin_test1.js"></script>
</body>
</html>
